package com.codingclub.infra.basic.utils;

import com.alibaba.druid.filter.config.ConfigTools;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;

/**
 * 数据库加密util
 *
 * @author: ChickenWing
 * @date: 2023/10/1
 */

public class DruidEncryptUtil {

    private static final String publicKey="MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAI0fIKOrl0mEmDlHnMb0gUe0uK9gw3xvpqS39VS0AZAK+O4iz/ICsKIZSG3RAJ/uxUqoyWdkQheaRX/XlALFEnkCAwEAAQ==";

    private static String privateKey="MIIBVQIBADANBgkqhkiG9w0BAQEFAASCAT8wggE7AgEAAkEAjR8go6uXSYSYOUecxvSBR7S4r2DDfG+mpLf1VLQBkAr47iLP8gKwohlIbdEAn+7FSqjJZ2RCF5pFf9eUAsUSeQIDAQABAkB3ELI7JUUplCPTACa4fgatdz7zSVLmJFWXWFY3NwCyhC6tVvIfuvhbZbTm5c/I0jvy4Dj7rkDzS8uD/KUjCNcBAiEAwE22w8P9HAujF/xzsJxt7bCIhPTeeaKHe8dHBGw3z6kCIQC73XaKitW8VmTtjtf/v6O/TxqhAbdruX00aTfunuwuUQIhAL73LazAXwTPxZlXOKfE4CFu8lNeO+P8c6CGp06MDOxpAiBTkYtmy6WSVxgkeLNrB/OuaWDeGGZgXC3u/5Mq6bUEUQIhAJomGmPIaV/TL8wSW8yjZBsI9BrDr/mI4MBgp80i2zHx";


    public static String encrypt(String plainText) throws Exception {

        String encrypt = ConfigTools.encrypt(privateKey,plainText);
        return encrypt;
    }

    public static String decrypt(String encryptText) throws Exception {
        String decrypt = ConfigTools.decrypt(publicKey, encryptText);
        return decrypt;
    }

    public static void main(String[] args) throws Exception {
        System.out.println(encrypt("zcjsuccess"));
    }

}

